from django.conf.urls import url

from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.routers import DefaultRouter

from .views import home, user, image, sku, order, permission, group, admin

urlpatterns = [
    # url(r'^authorizations/$', AdminLoginView.as_view()),
    # 用户名，id，token
    url(r'^authorizations/$', obtain_jwt_token),
    # 用户总量
    url(r'^statistical/total_count/$', home.UserTotalCountView.as_view()),
    # 日增用户
    url(r'^statistical/day_increment/$', home.UserDailyCountView.as_view()),
    # 日活跃用户
    url(r'^statistical/day_active/$', home.UserDailyActiveCountView.as_view()),
    # 日下单用户
    url(r'^statistical/day_orders/$', home.UserDailyOrderCountView.as_view()),
    # 月增用户的统计
    url(r'^statistical/month_increment/$', home.UserMonthCountView.as_view()),
    # 日分类商品访问量
    url(r'^statistical/goods_day_views/$', home.UserCategoryCountAPIView.as_view()),

    # ---------------用户模块------------------
    # 查询用户
    url(r'^users/$', user.UserListView.as_view()),

    # ---------------商品管理------------------
    # 保存图片
    url(r'^skus/simple/$', image.SKUView.as_view()),

    # SKU表管理，新增SKU商品-三级分类
    url(r'^skus/categories/$', sku.SKUCategoriesView.as_view()),
    # SKU表管理，新增SKU商品-获取spu名称
    url(r'^goods/simple/$', sku.SPUSimpleView.as_view()),
    # SKU表管理，新增SKU信息-获取spu商品规格
    url(r'^goods/(?P<pk>\d+)/specs/$', sku.SPUSpecView.as_view()),

    # 权限管理保存权限
    url(r'^permission/content_types/$', permission.ContentTypeView.as_view()),

    # 用户组保存数据-获取权限列表
    url(r'^permission/simple/$', group.GroupSimpleAPIView.as_view()),

    # 管理员管理－新增页面用户组展示
    url(r'^permission/groups/simple/$', admin.AdminSimpleView.as_view()),
]


# 定义视图集路由
# 1.创建router实例
router = DefaultRouter()
# 2.注册router
router.register(r'skus/images', image.ImageView, basename='image')
# 3.添加到urlpatterns
urlpatterns += router.urls

# sku页面展示
router.register(r'skus', sku.SKUModelViewSet, basename='skus')
urlpatterns += router.urls

# 订单页面展示
router.register(r'orders', order.OrderInfoView, basename='orders')
urlpatterns += router.urls

# 系统权限管理
router.register(r'permission/perms', permission.PermissionViewSet, basename='perms')
urlpatterns += router.urls

# 分组管理权限
router.register(r'permission/groups', group.GroupViewSet, basename='groups')
urlpatterns += router.urls

# 管理员管理
router.register(r'permission/admins', admin.AdminModelViewSet, basename='admins')
urlpatterns += router.urls
